package com.firebird.app.kotlin.stock.trend.fragment

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.Toast
import androidx.fragment.app.Fragment
import com.firebird.app.kotlin.stock.trend.R

/**
 * 首页导航中的Fragment
 * @author ljk
 * @date   2019年10月21日
 */
class FragmentNavigatorB( context: Context) : Fragment() {
    private var but1: Button? = null
    private var but2: Button? = null
    private var but3: Button? = null
    private var but4: Button? = null
    private var but5: Button? = null
    private var but6: Button? = null
    private var but7: Button? = null
    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
        val view: View = inflater.inflate(R.layout.fragment_navigator_b, null)
        but1 = view.findViewById<View>(R.id.but_1) as Button
        but2 = view.findViewById<View>(R.id.but_2) as Button
        but3 = view.findViewById<View>(R.id.but_3) as Button
        but4 = view.findViewById<View>(R.id.but_4) as Button
        but5 = view.findViewById<View>(R.id.but_5) as Button
        but6 = view.findViewById<View>(R.id.but_6) as Button
        but7 = view.findViewById<View>(R.id.but_7) as Button
        val listener = MyListener()
        but1!!.setOnClickListener(listener)
        but2!!.setOnClickListener(listener)
        but3!!.setOnClickListener(listener)
        but4!!.setOnClickListener(listener)
        but5!!.setOnClickListener(listener)
        but6!!.setOnClickListener(listener)
        but7!!.setOnClickListener(listener)
        return view
    }

    internal inner class MyListener : View.OnClickListener {
        override fun onClick(v: View) {
            when (v.id) {
                R.id.but_1 -> Toast.makeText(context, "but1被点击了~", Toast.LENGTH_SHORT).show()
                R.id.but_2 -> {
                }
                R.id.but_3 -> {
                }
                R.id.but_4 -> {
                }
                R.id.but_5 -> {
                }
                R.id.but_6 -> {
                }
                R.id.but_7 -> {
                }
                R.id.but_8 -> {
                }
            }
        }
    }

}